/**********************************************************************/
* Sarah Anzia and Rachel Bernhard                                      *
* August 17, 2021                                                      *
* REPLICATION CODE                                                     *
* "Gender Stereotyping and the Electoral Success of Women Candidates:  *
* New Evidence from Local Elections in the United States"	           */
/**********************************************************************/

* Load replication data

* Figure 1 (figure created in R, but here are numbers for text)
ttest win if council==1 & inc==0, by(female)
ttest win if mayor==1 & inc==0, by(female)
ttest win if schoolboard==1 & inc==0, by(female)

* Figure 2 (figures created in R, but here is analogous Stata code)

* mayor
twoway (histogram bush2004pc if inc==0 & female~=. & mayor==1 & city~="INDUSTRY", ///
 yaxis(2)) (lowess win bush2004pc if female==1 & mayor==1 & inc==0 & ///
 city~="INDUSTRY") (lowess win bush2004pc if female==0 & inc==0 & mayor==1 & ///
 city~="INDUSTRY")
 
* council
twoway (histogram bush2004pc if inc==0 & female~=. & council==1 & city~="INDUSTRY", ///
 yaxis(2)) (lowess win bush2004pc if female==1 & council==1 & inc==0 & ///
 city~="INDUSTRY") (lowess win bush2004pc if female==0 & inc==0 & council==1 & ///
 city~="INDUSTRY")

* school board
 twoway (histogram countybush2004pc if inc==0 & female~=. & schoolboard==1, ///
 yaxis(2)) (lowess win countybush2004pc if female==1 & schoolboard==1 & inc==0   ///
 ) (lowess win countybush2004pc if female==0 & inc==0 & schoolboard==1)

* Table 1: Win rates by gender, office, and policy domain

* column 1
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)
outreg using womentable3, se starlev(10 5 1) replace
lincom _Ifemale_1 + _IfemXmayor_1

* column 2
set matsize 1000
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.city i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)
outreg using womentable3, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXmayor_1

* column 3
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0 & competitive>1 & mixedsexrace==1, cluster(city)
outreg using womentable3, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXmayor_1

* column 4
xi: reg win i.female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1 & inc==0, cluster(cntyname)
outreg using womentable3, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXschoo_1

* column 5
xi: reg win i.female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year i.cntyname ///
if legraces==1 & inc==0, cluster(cntyname)
outreg using womentable3, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXschoo_1

* column 6
xi: reg win i.female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc lnpop_i i.year ///
if legraces==1 & inc==0 & competitive>1 & mixedsexrace==1, cluster(cntyname)
outreg using womentable3, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXschoo_1

* Figure 3 (figure created in R)

* Table 2: Win rates by constituency conservatism

* Column 1
xi: reg win i.female*crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)
outreg using womentable4, se starlev(10 5 1) replace

* Column 2
xi: reg win i.female*crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayor==1 & inc==0, cluster(City)
outreg using womentable4, se starlev(10 5 1) merge

* Column 3
xi: reg win i.female*ccountyrepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)
outreg using womentable4, se starlev(10 5 1) merge

* Figure 4 (figure created in R, but here are the numbers)
tabstat win if council==1 & inc==0 & female==1, by(timing)
tabstat win if council==1 & inc==0 & female==0, by(timing)

tabstat win if mayor==1 & inc==0 & female==1, by(timing)
tabstat win if mayor==1 & inc==0 & female==0, by(timing)

tabstat win if schoolboard==1 & inc==0 & female==1, by(timing)
tabstat win if schoolboard==1 & inc==0 & female==0, by(timing)

* Table 3: Win rates by gender and election timing

* Column 1
xi: reg win i.female*timing competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)
lincom _Ifemale_1 + _IfemXtimin_1
outreg using womentable6, se starlev(10 5 1) replace

* Column 2
xi: reg win i.female*timing competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayor==1 & inc==0, cluster(City)
lincom _Ifemale_1 + _IfemXtimin_1
outreg using womentable6, se starlev(10 5 1) merge

* Column 3
xi: reg win i.female*timing competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)
outreg using womentable6, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXtimin_1

* Column 4
xi: reg win i.female*crepub_pc i.female|timing c.timing#c.crepub_pc c.female#c.timing#c.crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)
outreg using womentable6, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXtimin_1
lincom _IfemXcrepu_1 + c.female#c.timing#c.crepub_pc

* Column 5
xi: reg win i.female*ccountyrepub_pc i.female|timing c.timing#c.ccountyrepub_pc c.female#c.timing#c.ccountyrepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)
outreg using womentable6, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXtimin_1
lincom _IfemXccoun_1 + c.female#c.timing#c.ccountyrepub_pc

/************************/
*    APPENDIX CODE       *
/************************/

* This code produces the numbers in Appendix A3 and in the text of the paper

* A3 Table: Candidates and races by gender

* Candidate-level information

codebook female if council==1 & female~=.
tab female if council==1 & female~=.
tab female if council==1 & female~=. & atlarge==1
tab female if council==1 & female~=. & districted==1
codebook female if mayor==1 & female~=.
tab female if mayor==1 & female~=.
codebook female if schoolboard==1 & female~=.
tab female if schoolboard==1 & female~=.
tab female if schoolboard==1 & female~=. & atlarge==1
tab female if schoolboard==1 & female~=. & districted==1

* Race-level information

* collapse data to race level 
collapse (median) cand vote competitive incsinrace incseatratio ///
femalesinrace sexidentifiedinrace racefemaleshare femaleinrace mixedsexrace ///
femalenonincinrace malenonincinrace allmalerace allfemalerace, ///
by(city City schooldist raceid office ///
council mayor schoolboard year districted atlarge)

gen incinrace = 1 if incsinrace>0 & incsinrace~=.
replace incinrace = 0 if incsinrace==0

* there are 2 races for which femaleinrace is blank. 
codebook femaleinrace if (mayor==1 | council==1 | schoolboard==1)
tab sexidentifiedinrace if mayor==1 | council==1 | schoolboard==1

tab council if sexidentifiedinrace~=0 & (mayor==1 | council==1 | schoolboard==1)
tab mayor if sexidentifiedinrace~=0 & (mayor==1 | council==1 | schoolboard==1)
tab schoolboard if sexidentifiedinrace~=0 & (mayor==1 | council==1 | schoolboard==1)

tab allmalerace if council==1
tab mixedsexrace if council==1
tab allfemalerace if council==1
tab femaleinrace if council==1
tab allmalerace if council==1 & districted==1
tab mixedsexrace if council==1 & districted==1
tab femaleinrace if council==1 & atlarge==1
tab femaleinrace if council==1 & districted==1

tab allmalerace if mayor==1
tab mixedsexrace if mayor==1
tab allfemalerace if mayor==1
tab femaleinrace if mayor==1
tab allmalerace if schoolboard==1
tab mixedsexrace if schoolboard==1
tab allfemalerace if schoolboard==1
tab femaleinrace if schoolboard==1
tab allmalerace if schoolboard==1 & districted==1
tab mixedsexrace if schoolboard==1 & districted==1
tab femaleinrace if schoolboard==1 & atlarge==1
tab femaleinrace if schoolboard==1 & districted==1

* Figures for Candidates per seat under Race-level information

tabstat competitive if council==1, by(allmalerace)
tabstat competitive if council==1 & districted==1, by(allmalerace)
tabstat competitive if council==1, by(mixedsexrace)
tabstat competitive if council==1 & districted==1, by(mixedsexrace)
tabstat competitive if council==1, by(femaleinrace)
tabstat competitive if council==1 & districted==1, by(femaleinrace)

tabstat competitive if mayor==1, by(allmalerace)
tabstat competitive if mayor==1, by(mixedsexrace)
tabstat competitive if mayor==1, by(femaleinrace)

tabstat competitive if schoolboard==1, by(allmalerace)
tabstat competitive if schoolboard==1 & districted==1, by(allmalerace)
tabstat competitive if schoolboard==1, by(mixedsexrace)
tabstat competitive if schoolboard==1 & districted==1, by(mixedsexrace)
tabstat competitive if schoolboard==1, by(femaleinrace)
tabstat competitive if schoolboard==1 & districted==1, by(femaleinrace)

clear

* Reload the candidate-level dataset

* For appendix A3, Proportion Women Candidates by Constituency Conservatism
* (figure was created in R, but here is analogous Stata code)

twoway (lowess female bush2004pc if council==1 & city~="INDUSTRY") (lowess female bush2004pc if ///
mayor==1) (lowess female countybush2004pc if schoolboard==1)

* Appendix A3 table: Average experience of men and women candidates

tabstat inc if council==1, by(female)
tabstat inc if mayor==1, by(female) 
tabstat inc if schoolboard==1, by(female)
ttest inc if council==1, by(female)
ttest inc if mayor==1, by(female)
ttest inc if schoolboard==1, by(female)

ttest mayorexper if council==1 & inc==0, by(female)
ttest mayorexper if mayor==1 & inc==0, by(female)
ttest mayorexper if schoolboard==1 & inc==0, by(female)

ttest councilexper if council==1 & inc==0, by(female)
ttest councilexper if mayor==1 & inc==0, by(female)
ttest councilexper if schoolboard==1 & inc==0, by(female)

ttest schoolboardexper if council==1 & inc==0, by(female)
ttest schoolboardexper if mayor==1 & inc==0, by(female)
ttest schoolboardexper if schoolboard==1 & inc==0, by(female)

ttest govtotherelected if council==1 & inc==0, by(female)
ttest govtotherelected if mayor==1 & inc==0, by(female)
ttest govtotherelected if schoolboard==1 & inc==0, by(female)

ttest business if council==1 & inc==0, by(female)
ttest business if mayor==1 & inc==0, by(female)
ttest business if schoolboard==1 & inc==0, by(female)

ttest law if council==1 & inc==0, by(female)
ttest law if mayor==1 & inc==0, by(female)
ttest law if schoolboard==1 & inc==0, by(female)

ttest education if council==1 & inc==0, by(female)
ttest education if mayor==1 & inc==0, by(female)
ttest education if schoolboard==1 & inc==0, by(female)

ttest activist if council==1 & inc==0, by(female)
ttest activist if mayor==1 & inc==0, by(female)
ttest activist if schoolboard==1 & inc==0, by(female)

* Figure A3.1: Proportion of Women by Office and Election Timing
* (this figure was created in R)

ttest female if council==1 & (timing==0 | timing==1), by(timing)
ttest female if mayor==1 & (timing==0 | timing==1), by(timing)
ttest female if schoolboard==1 & (timing==0 | timing==1), by(timing)

* Figure A3.2: Over-Time Change in the Proportion of Women Candidates, by Office
* (this figure was created in R)

* A4: first table is full results from Table 2. See above for code for Table 2.

* A4.1: Analysis using logit models

* Logit models:  Table 1 with logit instead of OLS

* column 1
xi: logit win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 2 (not shown in main paper)
xi: logit win i.female*mayor i.female|districted competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 3
xi:logit win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.city i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 4
xi: logit win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0 & competitive>1 & mixedsexrace==1, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 5
xi: logit win i.female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1 & inc==0, cluster(cntyname)
lincom _Ifemale_1 + _IfemXschoo_1

* column 6
xi: logit win i.female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year i.cntyname ///
if legraces==1 & inc==0, cluster(cntyname)
lincom _Ifemale_1 + _IfemXschoo_1

* column 7
xi: logit win i.female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc lnpop_i i.year ///
if legraces==1 & inc==0 & competitive>1 & mixedsexrace==1, cluster(cntyname)
lincom _Ifemale_1 + _IfemXschoo_1

* Logit models: Table 2 with logit instead of OLS

* Column 1
xi: logit win i.female*crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)

* Column 2
xi: logit win i.female*crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayor==1 & inc==0, cluster(City)

* Column 3
xi: logit win i.female*ccountyrepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)

* Logit models: Table 3 with logit instead of OLS

* Column 1
xi: logit win i.female*timing competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)
lincom _Ifemale_1 + _IfemXtimin_1

* Column 2
xi: logit win i.female*timing competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayor==1 & inc==0, cluster(City)
lincom _Ifemale_1 + _IfemXtimin_1

* Column 3
xi: logit win i.female*timing competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)
lincom _Ifemale_1 + _IfemXtimin_1

* Column 4
xi: logit win i.female*crepub_pc i.female|timing c.timing#c.crepub_pc c.female#c.timing#c.crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)
lincom _Ifemale_1 + _IfemXtimin_1
lincom _IfemXcrepu_1 + c.female#c.timing#c.crepub_pc

* Column 5
xi: logit win i.female*ccountyrepub_pc i.female|timing c.timing#c.ccountyrepub_pc c.female#c.timing#c.ccountyrepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)
lincom _Ifemale_1 + _IfemXtimin_1
lincom _IfemXccoun_1 + c.female#c.timing#c.ccountyrepub_pc


* A4.2: INCUMBENTS - Models from paper including incumbents

* Table 1 of paper but with incumbents

* column 1
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 2
xi: reg win i.female*mayor i.female|districted competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 3
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.city i.year ///
if mayorcouncilraces==1, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 4
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & competitive>1 & mixedsexrace==1, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 5
xi: reg win i.female*schoolboard competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1, cluster(cntyname)
lincom _Ifemale_1 + _IfemXschoo_1

* column 6
xi: reg win i.female*schoolboard competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year i.cntyname ///
if legraces==1, cluster(cntyname)
lincom _Ifemale_1 + _IfemXschoo_1

** column 7
xi: reg win i.female*schoolboard competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1 & competitive>1 & mixedsexrace==1, cluster(cntyname)
lincom _Ifemale_1 + _IfemXschoo_1

* Table 2 of paper but with incumbents

* Column 1
xi: reg win i.female*crepub_pc inc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1, cluster(City)

* Column 2
xi: reg win i.female*crepub_pc inc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayor==1, cluster(City)

* Column 3
xi: reg win i.female*ccountyrepub_pc inc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1, cluster(cntyname)


* Table 3 of paper but with incumbents included

* column 1
xi: reg win i.female*timing competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1, cluster(City)
lincom _Ifemale_1 + _IfemXtimin_1

* column 2
xi: reg win i.female*timing competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayor==1, cluster(City)
lincom _Ifemale_1 + _IfemXtimin_1

* column 3
xi: reg win i.female*timing competitive incseatratio lnpop_i ///
inc mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1, cluster(cntyname)
lincom _Ifemale_1 + _IfemXtimin_1

* Column 4
xi: reg win i.female*crepub_pc i.female|timing c.timing#c.crepub_pc c.female#c.timing#c.crepub_pc inc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1, cluster(City)
lincom _Ifemale_1 + _IfemXtimin_1

* Column 5
xi: reg win i.female*ccountyrepub_pc i.female|timing c.timing#c.ccountyrepub_pc c.female#c.timing#c.ccountyrepub_pc competitive inc incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1, cluster(cntyname)
lincom _Ifemale_1 + _IfemXtimin_1
lincom _IfemXccoun_1 + c.female#c.timing#c.ccountyrepub_pc

* A4.3: EXPERIENCE INTERACTED WITH FEMALE, select models

* column 1 - mayor vs. council
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
i.female|mexper i.female|cexper i.female|sbexper i.female|govtotherelectedinc ///
i.female|businessinc i.female|lawinc i.female|educationinc i.female|activistinc i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)

* column 2 - council vs. school board
xi: reg win i.female*schoolboard competitive incseatratio lnpop_i ///
i.female|mexper i.female|cexper i.female|sbexper i.female|govtotherelectedinc ///
i.female|businessinc i.female|lawinc i.female|educationinc i.female|activistinc i.year ///
if legraces==1 & inc==0, cluster(cntyname)

* column 3 - council interacted with Republican
xi: reg win i.female*crepub_pc competitive incseatratio lnpop_i ///
i.female|mexper i.female|cexper i.female|sbexper i.female|govtotherelectedinc ///
i.female|businessinc i.female|lawinc i.female|educationinc i.female|activistinc i.year ///
if council==1 & inc==0, cluster(City)

* column 4 - school board interacted with Republican
xi: reg win i.female*ccountyrepub_pc competitive incseatratio lnpop_i ///
i.female|mexper i.female|cexper i.female|sbexper i.female|govtotherelectedinc ///
i.female|businessinc i.female|lawinc i.female|educationinc i.female|activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)

* A4.4: Squared Republican vote and at-large districts

* column 1
xi: reg win i.female*crepub_pc i.female|crepub_pc_sq competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)

* column 2
xi: reg win i.female*schoolboard i.female|districted competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1 & inc==0, cluster(cntyname)

* column 3
xi: reg win i.female*schoolboard i.female|districted ///
i.schoolboard|districted c.female#c.districted#c.schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1 & inc==0, cluster(cntyname)

* column 4
xi: reg win i.female*schoolboard i.female|distvoteone competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1 & inc==0, cluster(cntyname)

* A4.5: CITIES WITH MAYORS ONLY

* column 1 - only cities with mayors
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0 & indmayor==1, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 2 - only cities with mayors, city FEs
xi: reg win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.city i.year ///
if mayorcouncilraces==1 & inc==0 & indmayor==1, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* Districted and at-large council elections
xi: reg win i.female*mayor i.female|districted competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)
outreg using womentable3, se starlev(10 5 1) merge
lincom _Ifemale_1 + _IfemXmayor_1

* A4.6 Analyses using Continuous GenderizeR Probabilities

* column 1 - council vs mayor
xi: reg win i.mayor*proportion_female competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)
lincom proportion_female + _ImayXpropo_1

** column 2 - council vs school board
xi: reg win i.schoolboard*proportion_female competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1 & inc==0 , cluster(cntyname)
lincom proportion_female + _IschXpropo_1

* column 3 - council, Repub.
xi: reg win proportion_female crepub_pc c.proportion_female#c.crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)

* column 4: school board, Repub.
xi: reg win proportion_female ccountyrepub_pc c.proportion_female#c.ccountyrepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)

* A4.7 Vote share as dependent variable

* column 1 - council vs mayor
xi: reg voteshare i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0 & vote==1, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* column 2, council vs school board
xi: reg voteshare i.female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if legraces==1 & inc==0 & vote==1, cluster(cntyname)
lincom _Ifemale_1 + _IfemXschoo_1

* Column 3: council races, Repub vote share
xi: reg voteshare i.female*crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0 & vote==1, cluster(City)

* Column 4: school board races, Repub vote share
xi: reg voteshare i.female*ccountyrepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0 & vote==1, cluster(cntyname)

* A4.8 Analyses using ambiguously gendered names
tab ambig_female
tab ambig_female if mayor==1 
tab ambig_female if mayor==1 & inc==0
tab ambig_female if council==1 
tab ambig_female if council==1 & inc==0
tab ambig_female if schoolboard==1
tab ambig_female if schoolboard==1 & inc==0
 
* column 1, model of city council races
xi: reg win i.clear_female ///
i.ambig_female competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)

* column 2, model of school board races
xi: reg win i.clear_female ///
i.ambig_female competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)

* column 3
xi: reg win i.clear_female*schoolboard ///
i.ambig_female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year i.cntyname ///
if legraces==1 & inc==0, cluster(cntyname)
lincom _Iclear_fem_1 + _IcleXschoo_1
lincom _Iambig_fem_1 + _IambXschoo_1

* Table: Election Timing Analysis with Ambiguous Names

* column 1
xi: reg win i.clear_female*timing ///
i.ambig_female*timing competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if council==1 & inc==0, cluster(City)
outreg using womentable6ambig, se merge
lincom _Iclear_fem_1 + _IcleXtimin_1
lincom _Iambig_fem_1 + _IambXtimin_1

* column 2
xi: reg win i.clear_female*timing ///
i.ambig_female*timing competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if schoolboard==1 & inc==0, cluster(cntyname)
lincom _Iclear_fem_1 + _IcleXtimin_1
lincom _Iambig_fem_1 + _IambXtimin_1

* A4.9 Additional fixed effects models

* Column 1: Council-mayor comparison, city-election date FE
xtset citydate_num
xi: xtreg win i.female*mayor competitive incseatratio ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc  ///
if mayorcouncilraces==1 & inc==0, fe vce(cluster city)

* Column 2: Council-mayor compraisons, race FE
xtset raceid
xi: xtreg win i.female*mayor ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc  ///
if mayorcouncilraces==1 & inc==0, fe vce(cluster city)

* Column 3, council-mayor comparisons, candidate FE
xtset candID_corrected
xi: xtreg win i.female*mayor competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayorcouncilraces==1 & inc==0 & indmayor==1, fe cluster(city)

* Second table, City councils and school districts, additional fixed effects models

* Column 1, council-school district comparisons, jurisdiction FE
xi: reg win i.female*schoolboard competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year i.cotermid ///
if legraces==1 & inc==0 & cotermid~=., cluster(cotermid)

* Column 2:  jurisdiction - election date FE

xtset jurisdate_num
xi: xtreg win i.female*schoolboard competitive incseatratio ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc  ///
if legraces==1 & inc==0, fe vce(cluster jurisname_num)

* Column 3: race ID FE, school vs. city council
xtset raceid
xi: xtreg win i.female*schoolboard ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc  ///
if legraces==1 & inc==0 & incseatratio~=. & ///
competitive~=. & lnpop_i~=., fe vce(cluster jurisname_num)

* Third table, Constituency conservatism, additional fixed effects models

* column 1
xtset citydate_num
xi: xtreg win i.female*crepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc  ///
if council==1 & inc==0, fe vce(cluster city)

* Column 2: race FE, Repub models, council 
xtset raceid
xi: xtreg win i.female*crepub_pc  ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc  ///
if council==1 & inc==0, fe vce(cluster city)

* Column 3, jurisdiction-election date FE, Repub models
xtset jurisdate_num 
xi: xtreg win i.female*ccountyrepub_pc competitive incseatratio lnpop_i ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc ///
if schoolboard==1 & inc==0, fe vce(cluster jurisname_num)

* Column 4, race FE, Repub models, schools
xtset raceid
xi: xtreg win i.female*ccountyrepub_pc  ///
mayorexperinc councilexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc ///
if schoolboard==1 & inc==0 & lnpop_i~=. ///
& competitive~=. & incseatratio~=., fe vce(cluster jurisname_num)
	
* A4.10: Alternative approaches, candidate experience

* Column 1:  take out experience & competitive measures
xi: reg win i.female*mayor lnpop_i ///
i.year ///
if mayorcouncilraces==1 & inc==0, cluster(city)
lincom _Ifemale_1 + _IfemXmayor_1

* Column 2:  limit to no council experience
xi: reg win female competitive incseatratio lnpop_i ///
mayorexperinc schoolboardexperinc govtotherelectedinc ///
businessinc lawinc educationinc activistinc i.year ///
if mayor==1 & inc==0 & councilexperinc==0, cluster(City)

* Column 3:  limit to no experience
xi: reg win female competitive incseatratio lnpop_i ///
i.year ///
if mayor==1 & inc==0 & councilexperinc==0 ///
& mayorexperinc==0 & businessinc==0 & educationinc==0, cluster(City)



